package com.rfs.suanfa;

public class 阶乘求和 {
    public static long f1(int N) {
        long ans=0;
        for (int i=1; i <= N; i++) {
            ans+=factorial(i);
        }
        return ans;
    }

    public static long factorial(int n) {
        long ans=1;
        for (int i = 1; i <= n; i++) {
            ans*=i;
        }
        return ans;
    }

    public static long f2(int N) {
        int ans=0;
        int cur=1;
        for (int i = 1; i <= N; i++) {
            cur=i*cur;
            ans+=cur;
        }
        return ans;
    }
    public static void main(String[] args) {
        System.out.println(f1(10));
        System.out.println(f2(10));
    }
}
